package kits

import (
	"crypto/md5"
	"crypto/sha256"
	"encoding/hex"
)

type digestTool struct{}

var Digest digestTool

// MD5String 对字符串MD5处理
func (dt *digestTool) MD5String(plain string) string {
	hMD5 := md5.New()
	hMD5.Write([]byte(plain))
	return hex.EncodeToString(hMD5.Sum(nil))
}

// SHA256String  对字符串SHA256处理
func (dt *digestTool) SHA256String(plain string) string {
	hSha256 := sha256.New()
	hSha256.Write([]byte(plain))
	return hex.EncodeToString(hSha256.Sum(nil))
}
